home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / commands / kermit / ckudia.c < prev    next >
C/C++ Source or Header  |  1990-07-19  |  27KB  |  912 lines

  1. char *dialv = "Dial Command, V2.0(009) 24 Jan 88";
  2.  
  3. /*  C K U D I A  --  Dialing program for connection to remote system */
  4.  
  5. /*
  6.  Author: Herm Fischer (HFISCHER@USC-ECLB)
  7.  Contributed to Columbia University for inclusion in C-Kermit.
  8.  Copyright (C) 1985, Herman Fischer, 16400 Ventura Blvd, Encino CA 91436
  9.  Permission is granted to any individual or institution to use, copy, or
  10.  redistribute this software so long as it is not sold for profit, provided this
  11.  copyright notice is retained. 
  12.  
  13.  ------
  14.  
  15.  This module should work under all versions of Unix.  It calls externally
  16.  defined system-depended functions for i/o, but depends upon the existence
  17.  of various modem control functions.
  18.  
  19.  This module, and the supporting routines in the ckutio.c module, assume
  20.  that the computer and modem properly utilize the following data communi-
  21.  cations signals (that means one should prepare the modem to use, not
  22.  circumvent, these signals):
  23.  
  24.      Data Terminal Ready:  This signal is asserted by the computer
  25.      when Kermit is about to ask the modem to dial a call, and is
  26.      removed when Kermit wishes to have the modem hang up a call.
  27.      The signal is asserted both while Kermit is asking the modem
  28.      to dial a specific number, and after connection, while Kermit
  29.      is in a data exchange mode.  
  30.  
  31.      Carrier detect:  This signal must be asserted by the modem when
  32.      a carrier is detected from a remote modem on a communications
  33.      circuit.  It must be removed by the modem when the circuit
  34.      disconnects or is hung up.  (Carrier detect is ignored while
  35.      Kermit is asking the modem to dial the call, because there is
  36.      no consistant usage of this signal during the dialing phase
  37.      among different modem manufacturers.)
  38.  
  39. */
  40.  
  41. /*
  42.  * Modifications:
  43.  *
  44.  *    21-Jul-85    Fixed failure returns hanging on no carrier signal
  45.  *            Requires tthang change too (ckutio.c revision)
  46.  *                            -- Herm Fischer
  47.  *
  48.  *    28-Jun-85    Fixed bug with defaulting the modem-failure message
  49.  *            in lbuf.
  50.  *                            -- Dan Schullman
  51.  *
  52.  *    27-Jun-85    Merged in code from Joe Orost at Berkeley for
  53.  *            supporting the US Robotics modem, which included
  54.  *            changing the single characters in MDMINF into
  55.  *            multi-character strings and modifying waitFor.
  56.  *                            -- Dan Schullman
  57.  *
  58.  *    26-Jun-85    Allow interrupts to be used to abort dialing,
  59.  *            and ring the bell when a connection is made.
  60.  *            Reorganized some of the failure paths to use the
  61.  *            same code, and now close the line on failures.
  62.  *            Allow use of stored numbers with the DF100 and
  63.  *            DF200 modems.  Handlers now declared after the
  64.  *            call to setjmp.
  65.  *                            -- Dan Schullman
  66.  *
  67.  *    24-May-85    DF03, DF100-series, DF200-series, and "unknown" modem
  68.  *            support added.  Also restructured the various data
  69.  *            tables, fixed some bugs related to missing data and
  70.  *            missing case labels, and modified the failure message
  71.  *            to display the "reason" given by the modem.
  72.  *                            -- Dan Schullman
  73.  *    16-Mar-87    Support for the ATT7300 UNIX PC internal modem was
  74.  *            added.
  75.  *                            -- Richard E. Hill
  76.  */
  77.  
  78. /*
  79.  * To add support for another modem, do the following:
  80.  *
  81.  *    Define a modem number symbol (n_XXX) for it, keeping the list
  82.  *    in alphabetical and numerical order, and renumbering the values
  83.  *    as necessary.
  84.  *
  85.  *    Create a MDMINF structure for it, again keeping the list alphabetical
  86.  *    for sanity's sake.
  87.  *
  88.  *    Add the address of the MDMINF structure to the ptrtab array, again
  89.  *    in alphabetical and numerical order.
  90.  *
  91.  *    Add the "user visible" modem name and corresponding modem number to
  92.  *    the mdmtab array, again in alphabetical order.
  93.  *
  94.  *    Read through the code and add modem-specific sections as necessary.
  95.  */
  96.  
  97. /*
  98.  * The intent of the "unknown" modem is hopefully to allow KERMIT to support
  99.  * unknown modems by having the user type the entire autodial sequence
  100.  * (possibly including control characters, etc.) as the "phone number".
  101.  * The only reason that the CONNECT command cannot be used to do this is
  102.  * that a remote line cannot normally be opened unless carrier is present.
  103.  *
  104.  * The protocol and other characteristics of this modem are unknown, with
  105.  * some "reasonable" values being chosen for some of them.  The only way to
  106.  * detect if a connection is made is to look for carrier present.
  107.  *
  108.  * SUPPORT IS CURRENTLY ONLY PARTIALLY SKETCHED OUT FOR THIS.  ALSO, IT
  109.  * SHOULD PERHAPS BE HANDLED MUCH EARLIER, SIMPLY READING USER INPUT AND
  110.  * SENDING IT TO THE MODEM AND ECHOING MODEM RESPONSES BACK TO THE USER,
  111.  * ALL THE TIME LOOKING FOR CARRIER.  OF COURSE, THE PROBLEM THEN BECOMES
  112.  * ONE OF ALLOWING THE USER TO ABORT THE DIALING.  WE COULD CHOOSE SOME
  113.  * PHRASE THAT WOULD PRESUMABLY NEVER BE A PART OF A VALID AUTODIAL SEQUENCE
  114.  * (E.G., "QUIT" and "quit"). -- DS
  115.  */
  116. #include "ckcdeb.h"
  117. #include <stdio.h>
  118. #include <ctype.h>
  119. #include <signal.h>
  120. #include "ckcker.h"
  121. #include "ckucmd.h"
  122.  
  123. #ifndef ZILOG
  124. #include <setjmp.h>            /* Longjumps */
  125. #else
  126. #include <setret.h>
  127. #endif
  128.  
  129. extern int flow, local, mdmtyp, quiet, speed, parity, seslog;
  130. extern char ttname[], sesfil[];
  131.  
  132. #ifndef MINIX
  133. #define    MDMINF    struct mdminf
  134.  
  135. MDMINF        /* structure for modem-specific information */
  136.     {
  137.     int        dial_time;    /* time modem allows for dialing (secs) */
  138.     char    *pause_chars;    /* character(s) to tell modem to pause */
  139.     int        pause_time;    /* time associated with pause chars (secs) */
  140.     char    *wake_str;    /* string to wakeup modem & put in cmd mode */
  141.     int        wake_rate;    /* delay between wake_str characters (msecs) */
  142.     char    *wake_prompt;    /* string prompt after wake_str */
  143.     char    *dmode_str;    /* string to put modem in dialing mode */
  144.     char    *dmode_prompt;    /* string prompt for dialing mode */
  145.     char    *dial_str;    /* dialing string, with "%s" for number */
  146.     int        dial_rate;    /* delay between dialing characters (msecs) */
  147.     };
  148.  
  149. /*
  150.  * Define symbolic modem numbers.
  151.  *
  152.  * The numbers MUST correspond to the ordering of entries
  153.  * within the ptrtab array, and start at one (1).
  154.  *
  155.  * It is assumed that there are relatively few of these
  156.  * values, and that the high(er) bytes of the value may
  157.  * be used for modem-specific mode information.
  158.  *
  159.  * REMEMBER that only the first eight characters of these
  160.  * names are guaranteed to be unique.
  161.  */
  162.  
  163. #define        n_CERMETEK     1
  164. #define        n_DF03         2
  165. #define        n_DF100         3
  166. #define        n_DF200         4
  167. #define        n_GDC         5
  168. #define        n_HAYES         6
  169. #define        n_PENRIL     7
  170. #define        n_RACAL         8
  171. #define        n_UNKNOWN     9
  172. #define        n_USROBOT    10
  173. #define        n_VENTEL    11
  174. #define         n_CONCORD       12
  175. #define        n_ATT7300    13    /* added for PC7300 */
  176.  
  177. /*
  178.  * Declare modem "variant" numbers for any of the above for which it is
  179.  * necessary to note various operational modes, using the second byte
  180.  * of a modem number.
  181.  *
  182.  * It is assumed that such modem modes share the same modem-specific
  183.  * information (see MDMINF structure) but may differ in some of the actions
  184.  * that are performed.
  185.  */
  186. #define        n_HAYESNV    ( n_HAYES + ( 1<<8 ) )
  187.  
  188. /*
  189.  * Declare structures containing modem-specific information.
  190.  *
  191.  * REMEMBER that only the first SEVEN characters of these
  192.  * names are guaranteed to be unique.
  193.  */
  194.  
  195. static
  196. MDMINF CERMETEK =    /* information for "Cermetek Info-Mate 212 A" modem */
  197.     {
  198.     20,            /* dial_time */
  199.     "BbPpTt",        /* pause_chars */
  200.     0,            /* pause_time */    /** unknown -- DS **/
  201.     "  XY\016R\r",    /* wake_str */
  202.     200,        /* wake_rate */
  203.     "",            /* wake_prompt */
  204.     "",            /* dmode_str */
  205.     "",            /* dmode_prompt */
  206.     "\016D '%s'\r",    /* dial_str */
  207.     200            /* dial_rate */
  208.     };
  209.  
  210. static
  211. MDMINF DF03 =        /* information for "DEC DF03-AC" modem */
  212.     {
  213.     27,            /* dial_time */
  214.     "=",        /* pause_chars */    /* wait for second dial tone */
  215.     15,            /* pause_time */
  216.     "\001\002",        /* wake_str */
  217.     0,            /* wake_rate */
  218.     "",            /* wake_prompt */
  219.     "",            /* dmode_str */
  220.     "",            /* dmode_prompt */
  221.     "%s",        /* dial_str */
  222.     0            /* dial_rate */
  223.     };
  224.  
  225. static
  226. MDMINF DF100 =        /* information for "DEC DF100-series" modem */
  227.             /*
  228.              * The telephone "number" can include "P"s and/or "T"s
  229.              * within it to indicate that subsequent digits are
  230.              * to be dialed using pulse or tone dialing.  The
  231.              * modem defaults to pulse dialing.  You may modify
  232.              * the d